<?php
	define('CONFIG_FILE',true);
    include '../config.php';
    
	define('DB_FILE',true);
	require_once '../Tool/DB/SqlDBManager.class.php';

	session_start();
	if (empty($_SESSION["userType"])) {
		$url="../Index.php";
		include_once '../Tool/Common/Redirect.php';
		exit();
	}

	if($_SESSION["userType"]=="Therapy Assistant"){
        $url="../Index.php";
		include_once '../Tool/Common/Redirect.php';
		exit();
    }
    
	$Username = $_SESSION['username'];

	$sqlDBManager = new SqlDBManager();
	
	$sql = "UPDATE attendancerecord SET Status = ?,AuditVerify=? WHERE Date (SignInTimeStamp) = CURDATE()";
	$parameters = array('Verified',$Username);
	$res=$sqlDBManager->execute_dml($sql,$parameters);

	//close connection
  	$sqlDBManager->close_connect();
  	
	if ($res>0) {
		echo json_encode(array('success' => true));
	} else {
		echo json_encode(array('msg' => "Update attendance record failed due to database error."));
	}
?>